<?php
class LoaicdcbsController extends AppController {

	var $name = 'Loaicdcbs';

	function index() {
		$this->Loaicdcb->recursive = 0;
		$this->set('loaicdcbs', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid loaicdcb', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('loaicdcb', $this->Loaicdcb->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Loaicdcb->create();
			if ($this->Loaicdcb->save($this->data)) {
				$this->Session->setFlash(__('The loaicdcb has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The loaicdcb could not be saved. Please, try again.', true));
			}
		}
		$namhocs = $this->Loaicdcb->Namhoc->find('list');
		$xeploais = $this->Loaicdcb->Xeploai->find('list');
		$chidoancbs = $this->Loaicdcb->Chidoancb->find('list');
		$this->set(compact('namhocs', 'xeploais', 'chidoancbs'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid loaicdcb', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Loaicdcb->save($this->data)) {
				$this->Session->setFlash(__('The loaicdcb has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The loaicdcb could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Loaicdcb->read(null, $id);
		}
		$namhocs = $this->Loaicdcb->Namhoc->find('list');
		$xeploais = $this->Loaicdcb->Xeploai->find('list');
		$chidoancbs = $this->Loaicdcb->Chidoancb->find('list');
		$this->set(compact('namhocs', 'xeploais', 'chidoancbs'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for loaicdcb', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Loaicdcb->delete($id)) {
			$this->Session->setFlash(__('Loaicdcb deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Loaicdcb was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>